package Demo2;

public class Test {
    public static void main1(String[] args) {
        Rect rect=new Rect();
        Triangle triangle=new Triangle();
        String[] strings={"rect","triangle","triangle"};
        for(String s:strings){
            if(s.equals("rect")){
                rect.getShape();
            }else{
                triangle.getShape();
            }
        }
    }

    public static void main(String[] args) {
        Rect rect=new Rect();
        Triangle triangle=new Triangle();
        Shape[] shapes={rect,triangle,rect};
        for(Shape shape:shapes){
            shape.getShape();
        }
    }
}
